package com.os.common.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
/**
 * 敏感信息校验
 * 部分接口需要作敏感信息验证
 * 参见：https://blog.csdn.net/liucy007/article/details/123827715
 * 见：工作流-任务类型详情页
 */
@Component
@Aspect
@EnableAspectJAutoProxy(proxyTargetClass = true)
@Order(value = Ordered.LOWEST_PRECEDENCE)
//@Order(value = Ordered.)
public class SensitiveAnnotationAspect {
    @Pointcut("@annotation(com.os.common.aop.SensitiveAnnotation)")
    public void annotationPointCut() {
    }

    /**
     * 环绕通知
     */
    @Around("annotationPointCut()")
    public Object update(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("around begin...");
        //执行到这里走原来的方法
        return joinPoint.proceed();
       // System.out.println("around after....");
    }

//    /**
//     * 环绕通知
//     */
//    @Around("annotationPointCut()")
//    public void advice(ProceedingJoinPoint joinPoint) throws Throwable {
//        System.out.println("around begin...");
//        //执行到这里走原来的方法
//        joinPoint.proceed();
//        System.out.println("around after....");
//    }

    @Before("annotationPointCut()")
    public void record(JoinPoint joinPoint) {
        System.out.println("Before");
    }

    @After("annotationPointCut()")
    public void after() {
        System.out.println("After");
    }
}
